{extend name="base"/}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="/public/css/order.css">
<style>
    .silider-express{padding-left: 10px;background: #fff;font-size: 12px;}
    .logistics-tracking{padding-left:5px;}
    .popover-content{width:700px;}
    .popover{max-width:900px;}
	
	.n_tab_line a {padding: 0 20px;}
</style>
{/block}
{block name="main"}
<div class="mod-table">
    <div class="n_tab_line">
        <a href="{:url('order/OrderList')}" class="n_tab_list02" onclick="ding('12','27');">订单列表</a>
        <a href="javascript:;" class="n_tab_add02">订单详情</a>
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
        <div class="cl"></div>
    </div>
    {if condition="$order['order_status'] lt 5 && $order['order_status'] gt 0"}
    <div class="step-region">
        <ul class="ui-step ui-step-4">
            <li class="ui-step-done"><div class="ui-step-title">买家下单</div><div class="ui-step-number">1</div><div class="ui-step-meta">{$order['create_time']|date='Y-m-d H:i:s',###}</div></li>
            <li class="{if condition='$order["order_status"] gt 0'}ui-step-done{/if}"><div class="ui-step-title">买家付款</div><div class="ui-step-number">2</div><div class="ui-step-meta">{if condition='$order["order_status"] gt 0'}{$order['pay_time']|date='Y-m-d H:i:s',###}{/if}</div></li>
            <li class="{if condition='$order["order_status"] gt 1'}ui-step-done{/if}"><div class="ui-step-title">商家发货</div><div class="ui-step-number">3</div><div class="ui-step-meta">{if condition='$order["order_status"] gt 1'}{$order['consign_time']|date='Y-m-d H:i:s',###}{/if}</div></li>
            <li class="{if condition='$order["order_status"] eq 3'}ui-step-done{/if}"><div class="ui-step-title">交易完成</div><div class="ui-step-number">4</div><div class="ui-step-meta">{if condition='$order["order_status"] eq 3'}{$order['sign_time']|date='Y-m-d H:i:s',###}{/if}</div></li>
        </ul>
    </div>
    {/if}
    <div class="step-region clearfix">
        <div class="info-region">
            <div class="info-div">订单信息<span class="secured-title">担保交易</span></div>
            <table class="info-table">
                <tbody>
                <tr><th>订单编号：</th><td>{$order['order_no']}</td></tr>
                <tr style="display: table-row;"><th>订单类型：</th><td>普通订单</td></tr>
                <tr><th>付款方式：</th><td>在线支付</td></tr>
                <tr><th>买家：</th><td><span>{$order['user_name']}</span></td></tr>
                </tbody>
            </table>
            <div class="dashed-line"></div>
            <table class="info-table">
                <tbody>
                <tr><th>配送方式：</th><td>{$order['shipping_type_name']}&nbsp;&nbsp;{$order['shipping_company_name']}</td></tr>
                {switch name="$order.shipping_type"}
                {case value="1"}
                <!-- 物流 -->
                <tr>
                    <th>收货信息：</th>
                    <td>
                        <p>{$order['receiver_name']}，{$order['receiver_mobile']}，{$order['address']}&nbsp;{$order['receiver_address']}{if condition="$order['receiver_zip']!=''"}&nbsp;，{$order['receiver_zip']}{/if}</p>
                    </td>
                </tr>
                {/case}
                {case value="2"}
                <!-- 自提 -->
                <tr>
                    <th>自提地址：</th>
                    <td>
                        <p>{$order['order_pickup']['province_name']}&nbsp;{$order['order_pickup']['city_name']}&nbsp;{$order['order_pickup']['dictrict_name']}&nbsp;{$order['order_pickup']['address']}</p>
                    </td>
                </tr>
                {/case}
                {/switch}
                {if condition="!empty($order['buyer_invoice_info'])"}
                <tr>
                    <th>发票抬头：</th>
                    <td>
                        {if condition="!empty($order['buyer_invoice_info'][0])"}
                        {$order['buyer_invoice_info'][0]}
                        {/if}
                    </td>
                </tr>
                <tr>
                    <th>纳税人识别号：</th>
                    <td>
                        {if condition="!empty($order['buyer_invoice_info'][2])"}
                        {$order['buyer_invoice_info'][2]}
                        {else/}
                        -
                        {/if}
                    </td>
                </tr>
                <tr>
                    <th>发票内容：</th>
                    <td>
                        {if condition="!empty($order['buyer_invoice_info'][1])"}
                        {$order['buyer_invoice_info'][1]}
                        {/if}
                    </td>
                </tr>
                {/if}
                <tr>
                    <th>买家留言：</th>
                    {if condition="$order['buyer_message'] !=''"}
                    <td>{$order['buyer_message']}</td>
                    {else/}
                    <td>此订单没有留言</td>
                    {/if}
                </tr>
                {if condition="$order['seller_memo'] != ''"}
                <tr>
                    <th>卖家备注：</th>
                    <td>{$order['seller_memo']}</td>
                </tr>
                {/if}
                </tbody>
            </table>
        </div>
        <div class="state-region">
            <div style="padding: 0px 0px 30px 40px;">
                <div class="state-title"><span class="icon info">!</span>订单状态：{$order['status_name']}</div>
            </div>
            <div class="state-remind-region">
                <div class="dashed-line"></div>
                <div class="state-remind"><div class="tixing">提醒：</div>
                    <ul><li>如果无法发货，请及时与买家联系并说明情况后进行退款；</li>
                        <li>买家申请退款后，须征得买家同意后再发货，否则买家有权拒收货物；</li>
                        <li>买家付款后超过7天仍未发货，将有权申请客服介入发起退款维权；</li>
                        <li><div class="tixing">可改价商品改价后按回车键即可</div></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <table class="ui-table ui-table-simple goods-table order-detail-goods-table">
        <thead>
        <tr>
            <th style="width:8%;">商品图</th>
            <th class="cell-10" style="width:30%;">商品</th>
            <th style="width:10%;">数量</th>
            <th style="width:10%;">订单价格(元)</th>
            <th style="width:8%;">优惠券(元)</th>
            <th style="width:8%;">会员折扣(元)</th>
            <th style="width:8%;">运费(元)</th>
            <th class="cell-13" style="width:10%;">实付款价格(元)</th>
            <th style="width:15%;">配送状态</th>
        </tr>
        </thead>
        <tbody>
        <!-- 待发货商品 -->
        {if $order['order_goods_no_delive']}
        {volist name="order['order_goods_no_delive']" id="vo"}
        <tr class="test-item">
            <td class="td-goods-image" rowspan="1">
                <div class="ui-centered-image" style="width: 48px; height: 48px;">
                    <img src="{$vo['picture_info']['img_cover']}" style="max-width: 48px; max-height: 48px;">
                </div>
            </td>
            <td class="cell-10" style="width:200px;">
                <a href="/admin/goods/goodsinfo?goodsid={$vo['goods_id']}" target="_blank">{$vo['goods_name']}</a>
                <p class="c-gray">{$vo['sku_name']}</p>
            </td>
            <td>{$vo['num']}</td>
            <td>{$vo['price']}</td>
            <td><p>{$list.coupon_money}</p></td>
            <td><p>{$list.rebate_money}</p></td>
            <td><p>{$list.shipping_money}</p></td>
            <td><p>{$list.pay_money}</p></td>
            <td>
                <p>{:getOrderStatus($order['order_status'])}</p>
            </td>
        </tr>
        <tr><td colspan="9"></td></tr>
        {/volist}
        {/if}
        <!-- 已发货 -->
        {if $order['goods_packet_list']}
        {volist name="order['goods_packet_list']" id="v" key=key}
        <tr style="background-color:#f2f2f2;color:#999;font-weight:bold;">
            <td colspan="7"><a href="javascript:;" style="color:rgba(34, 34, 34, 0.71);font-size:14px;">{$v['packet_name']}</a>&nbsp;&nbsp;&nbsp;&nbsp;
                {if condition="$v['is_express'] eq 1"}
                {$v['express_name']}&nbsp;&nbsp;运单号:{$v['express_code']}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" data-html="true" class="logistics-tracking" data-container="body" data_express="{$v['express_name']}" data-placement="top" data-trigger="manual" goods_id="{$v['express_id']}" data-show="1">物流跟踪</a>
                {/if}
            </td>
        </tr>
        {volist name="$v['order_goods_list']" id="vo"}
        <tr class="test-item">
            <td class="td-goods-image" rowspan="1">
                <div class="ui-centered-image" style="width: 48px; height: 48px;">
                    <img src="{$vo['picture_info']['img_cover']}" style="max-width: 48px; max-height: 48px;">
                </div>
            </td>
            <td class="cell-10" style="width:200px;">
                <a href="javascript:;" target="_blank">{$vo['goods_name']}</a>
                <p class="c-gray">{$vo['sku_name']}</p>
            </td>
            <td>{$vo['price']}</td>
            <td>{$vo['num']}</td>
            <td><p>{$vo['goods_money']}</p></td>
            <td>
                <p>
                    {$order['shipping_status_name']}
                </p>
            </td>
        </tr>
        {/volist}
        {/volist}
        {/if}
        </tbody>
        <tfoot>
        <tr>
            <td colspan="9" class="text-right">
                <span>商品总金额：￥{$order['order_money']}，</span>
                {if condition="$order['user_platform_money']>0"}
                <span>余额支付：￥{$order['user_platform_money']}，</span>
                {/if}
                {if condition="$order['coupon_money']>0"}
                <span>优惠券：￥{$order['coupon_money']}，</span>
                {/if}
                {if condition="$order['tax_money']>0"}
                <span>发票税额：￥{$order['tax_money']}，</span>
                {/if}
                {if condition="$order['discount_money']>0"}
                <span>满减优惠：￥{$order['discount_money']}，</span>
                {/if}
                {if condition="$order['point']>0"}
                <span>使用积分：{$order['point']}，</span>
                {/if}
                {if $order['status_name']=='待支付'}
                <span>实际需支付：<input type="text" value="{$order['pay_money']}" style="border:1px solid #eeeeee;height:28px;line-height: 28px;padding-left:5px;" onchange="update_money(this.value)"></span>
                {else}
                <span> 实际需支付：<b class="real-pay c-red">￥{$order['pay_money']}</b></span>
                {/if}
                <span>（含运费 ￥{$order['shipping_money']}）</span>
            </td>
        </tr>
        </tfoot>
    </table>
</div>
<input type="hidden" id="order_id" value="{$order['order_id']}" />
<input type="hidden" id="old_pay" value="{$order['pay_money']}" />
<input type="hidden" id="out_trade_no" value="{$order['out_trade_no']}" />
<script type="text/javascript">
    $(function(){
        //查询物流
        $(".logistics-tracking").mouseover(function(){
            $(".logistics-tracking").removeAttr("data-show");
            $(this).attr("data-show",1);
        });
        var html = '';
        $(".logistics-tracking").hover(function(){
            var curr = $(this);
            var order_goods_id = curr.attr('goods_id');
            var express_name = curr.attr('data_express');
            $.ajax({
                type : "post",
                url : "{:url('order/getexpressinfo')}",
                data : {"order_goods_id":order_goods_id},
                beforeSend : function(){
                    html = '<div class="silider-express">';
                    html += '<div class="mask-layer-loading" style="text-align:center;">';
                    html += '<img src="ADMIN_IMG/mask_load.gif"/>';
                    html += '<div style="text-align:center;margin-top:10px;">努力加载中...</div>';
                    html += '</div>';
                    html += '</div>';
                    $(".logistics-tracking").popover({content : html});
                    curr.popover("show");
                },
                success : function(data) {
                    html = '<div class="silider-express">';
                    html += '<div class="express_names">快递公司:'+express_name+'</div>';
                    html += '<div>';
                    html += '<div>物流跟踪：</div>';
                    if (data.length > 0) {
                        for (var i = 0; i < data.length; i++){
                            html += '<p style="width:76%;float:left;">'+ data[i]["AcceptStation"]+'</p>';
                            html += '<p style="width:24%;float:right;">'+ data[i]["AcceptTime"]+'</p>';
                        }
                    } else {
                        html += '<p style="width:76%;float:left;">'+ data["Reason"]+'</p>';
                    }
                    html += '</div>';
                    html += '</div>';
                    curr.popover("destroy");
                    curr.popover({content : html});
                    curr.popover("show");
                }
            });
        },function(){
            $(this).popover("hide");
        });
    })
    function update_money(money) {
        var id=$("#order_id").val();
        var out_trade_no=$("#out_trade_no").val();
        var old_pay=$("#old_pay").val();
        $.ajax({
            type : "post",
            url : "__CONF_SITE__admin/order/change_money",
            data : {
                "id" : id,
                "out_trade_no" : out_trade_no,
                "old_pay" : old_pay,
                'val':money
            },
            success : function(data) {
                if (data=='2') {
                    layer.msg('成功!',{icon:1,time:1000},function () {
                        window.location.reload();
                    });
                }
                else
                {
                    layer.msg('失败', {icon: 2, time: 1000});
                }
            }
        })
    }
</script>
{/block}